//
//  BankViewCell.m
//  NiuBanGold
//
//  Created by Billy on 15/11/26.
//  Copyright © 2015年 zzjr. All rights reserved.
//

#import "BankViewCell.h"
#import "UIImageView+WebCache.h"

@interface BankViewCell ()

@property (nonatomic, strong) UIImageView *imageView_bankImg;
@property (nonatomic,strong) UILabel *label_limit; //限额
@property (nonatomic,strong) UILabel *label_name; //银行名字

@end

@implementation BankViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        [self setBackgroundColor:[UIColor whiteColor]];
        [self subViewsCreation];
    }
    
    return self;
}

#pragma mark - sub view createon

- (void) subViewsCreation {
    
    //银行图标
    self.imageView_bankImg = [[UIImageView alloc] initWithFrame:CGRectMake(MULTIPLYWIDTH(27.0/2), MULTIPLYHEIGHT(34.0/2), MULTIPLYWIDTH(54.0/2), MULTIPLYHEIGHT(54.0/2))];
    
    //银行名字
    self.label_name = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.imageView_bankImg.frame) + MULTIPLYWIDTH(20.0/2), MULTIPLYHEIGHT(32.0/2), SCREEN_WIDTH - MULTIPLYWIDTH(101/2), MULTIPLYHEIGHT(33./2))];
    [self.label_name setTextColor:[UsefulUtil colorWithHexString:@"#434343"]];
    [self.label_name setFont:[UIFont systemFontOfSize:15.0]];
    [self.label_name setAdjustsFontSizeToFitWidth:YES];
    
    //限额
    self.label_limit = [[UILabel alloc] initWithFrame:CGRectMake(self.label_name.frame.origin.x, CGRectGetMaxY(self.label_name.frame) + MULTIPLYHEIGHT(12.0/2), SCREEN_WIDTH -MULTIPLYWIDTH(101/2) , MULTIPLYHEIGHT(24.0/2))];
    
    [self.label_limit setTextColor:[UsefulUtil colorWithHexString:@"#989898"]];
    [self.label_limit setFont:[UIFont systemFontOfSize:11.0]];
    [self.label_limit setAdjustsFontSizeToFitWidth:YES];
    
    [self.contentView addSubview:self.imageView_bankImg];
    [self.contentView addSubview:self.label_name];
    [self.contentView addSubview:self.label_limit];
    
    UIView *view_sep = [UsefulUtil viewCreationWithFrame:CGRectMake(0, MULTIPLYHEIGHT(119.0/2), SCREEN_WIDTH, MULTIPLYHEIGHT(1.0/2)) backgroundColor:[UsefulUtil colorWithHexString:@"#c8c7cc"] backGroundImage:nil];
    [self.contentView addSubview:view_sep];
}

//赋值

- (void)layoutSubviews {
    
    if (self.bank.bank_imgUrl) {
        
        [self.imageView_bankImg sd_setImageWithURL:[NSURL URLWithString:self.bank.bank_imgUrl]];
    }

    
    [self.label_name setText:self.bank.bank_name];
    
    NSString *content = [NSString stringWithFormat:@"单笔%@元，单日%@元，单月%@元",(self.bank.bank_singleAmt.floatValue == 0.0? @"不限":self.bank.bank_singleAmt) ,(self.bank.bank_dayAmt.floatValue == 0.0? @"不限":self.bank.bank_dayAmt),(self.bank.bank_monthAmt.floatValue == 0.0? @"不限":self.bank.bank_monthAmt)];
    
    [self.label_limit setText:content];
}

@end
